

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="XiaoMaDing">
  <meta name="keywords" content="">
  
    <meta name="description" content="业务背景 交易支付对账：需要将商户与支付平台间对账自动化，确保商户信息流、支付平台资金链的一致性。 业务对账：需要将上下游业务系统间的对账自动化，确保业务数据一致性，提前发现问题，提高用户体验。 数据对账：系统重构后数据双写、数据迁移等场景间的数据对账自动化，确保双写一致性。  目标□ 业务层面：  实现对账、差错处理的的自动化、工具化，即可能的减少人工介入。 可以便捷的获取需要核对的原始数据，如">
<meta property="og:type" content="article">
<meta property="og:title" content="系统设计：通用对账中心">
<meta property="og:url" content="http://example.com/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/index.html">
<meta property="og:site_name" content="剑出">
<meta property="og:description" content="业务背景 交易支付对账：需要将商户与支付平台间对账自动化，确保商户信息流、支付平台资金链的一致性。 业务对账：需要将上下游业务系统间的对账自动化，确保业务数据一致性，提前发现问题，提高用户体验。 数据对账：系统重构后数据双写、数据迁移等场景间的数据对账自动化，确保双写一致性。  目标□ 业务层面：  实现对账、差错处理的的自动化、工具化，即可能的减少人工介入。 可以便捷的获取需要核对的原始数据，如">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://example.com/index_img/check-center.png">
<meta property="article:published_time" content="2023-08-05T11:45:34.000Z">
<meta property="article:modified_time" content="2023-12-26T03:48:16.432Z">
<meta property="article:author" content="XiaoMaDing">
<meta property="article:tag" content="通用对账中心">
<meta property="article:tag" content="QLExpress">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="http://example.com/index_img/check-center.png">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>系统设计：通用对账中心 - 剑出</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.5-a","typing":{"enable":true,"typeSpeed":40,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"left","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":4},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":true,"follow_dnt":false,"baidu":"e0dcc0c9ab8f117bb83579322e04efb8","google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml","include_content_in_search":true};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  

  
    <!-- Baidu Analytics -->
    <script async>
      if (!Fluid.ctx.dnt) {
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?e0dcc0c9ab8f117bb83579322e04efb8";
          var s = document.getElementsByTagName("script")[0];
          s.parentNode.insertBefore(hm, s);
        })();
      }
    </script>
  

  

  

  

  

  



  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 60vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>剑出</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/yuzhou.gif') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="系统设计：通用对账中心"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2023-08-05 19:45" pubdate>
          2023年8月5日 晚上
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          5.7k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          48 分钟
        
      </span>
    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="padding-left: 2rem; margin-right: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <h1 id="seo-header">系统设计：通用对账中心</h1>
            
              <p class="note note-info">
                
                  
                    本文最后更新于：7 个月前
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <h1 id="业务背景"><a href="#业务背景" class="headerlink" title="业务背景"></a>业务背景</h1><ul>
<li>交易支付对账：需要将商户与支付平台间对账自动化，确保商户信息流、支付平台资金链的一致性。</li>
<li>业务对账：需要将上下游业务系统间的对账自动化，确保业务数据一致性，提前发现问题，提高用户体验。</li>
<li>数据对账：系统重构后数据双写、数据迁移等场景间的数据对账自动化，确保双写一致性。</li>
</ul>
<h1 id="目标"><a href="#目标" class="headerlink" title="目标"></a>目标</h1><p>□ 业务层面：</p>
<ul>
<li>实现对账、差错处理的的自动化、工具化，即可能的减少人工介入。</li>
<li>可以便捷的获取需要核对的原始数据，如平台数据、三方数据</li>
<li>可以灵活配置清洗、过滤、核对规则</li>
<li>可以查看核对的结果，可以对差异进行追踪管理、处理，可以对外提供核对结果</li>
</ul>
<p>□ 技术层面：</p>
<ul>
<li>具备通用对账能力，可适应多种对账场景</li>
<li>业务方能快速接入</li>
<li>可以应对大数据量的对账</li>
<li>具有较强的扩展能力</li>
</ul>
<h1 id="调研"><a href="#调研" class="headerlink" title="调研"></a>调研</h1><figure><div class="code-wrapper"><pre class="line-numbers language-properties" data-language="properties"><code class="language-properties"><span class="token comment"># 陈元宇宙：对账系统从入门到精通 (基于产品视角)</span>
<span class="token key attr-name">http</span><span class="token punctuation">:</span><span class="token value attr-value">//paypm.cn/h-nd-81.html#_np=2_1268</span>
<span class="token comment">#  卡拉云：如何设计财务对账系统 —— 从0到1搭建对账中心实战 (标准化入库还是没说，标准账单字段)</span>
<span class="token key attr-name">https</span><span class="token punctuation">:</span><span class="token value attr-value">//blog.csdn.net/weixin_48201324/article/details/118805747</span>
<span class="token comment"># 有赞业务对账平台的探索与实践 (整体架构比较好，抽象了4个步骤的接口，采用SPI，无细节)</span>
<span class="token key attr-name">https</span><span class="token punctuation">:</span><span class="token value attr-value">//tech.youzan.com/practice-of-business-check-platform-in-youzan/</span>
<span class="token comment"># 美团配送资金安全治理之对账体系建设 (比较全面，但是没有落地细节)</span>
<span class="token key attr-name">https</span><span class="token punctuation">:</span><span class="token value attr-value">//tech.meituan.com/2018/03/21/balance-accounts.html</span>
<span class="token comment"># 支付对账系统怎么设计 (基于数据库的核对对账逻辑demo)</span>
<span class="token key attr-name">https</span><span class="token punctuation">:</span><span class="token value attr-value">//mp.weixin.qq.com/s/SOpwMsVB5wNkwMZdKKMkwg</span>
<span class="token comment"># 苏宁基于 Apache Ignite 日均十亿数据对账实践应用 (分布式内存计算，无细节)</span>
<span class="token key attr-name">https</span><span class="token punctuation">:</span><span class="token value attr-value">//www.sohu.com/a/274723469_804130</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div></figure>

<p>市面上对于对账中心的架构设计文章是比较多的，但是具体怎么落地，很多细节还是很欠缺。</p>
<p>笔者的目标是根据调研结果，设计一个符合本公司业务及体量的通用对账系统，并且落地实现。</p>
<h1 id="难题"><a href="#难题" class="headerlink" title="难题"></a>难题</h1><p>1、对账数据源格式不一，怎么标准化存储？</p>
<p>既然格式不一，那就不标准化，直接存储CSV文件；然后配置字段名、核对键等元数据，使用时，根据元数据配置，解析为Map，在核对引擎中去做具体的核对处理。</p>
<p>2、如何根据配置，进行灵活的数据清洗、过滤、核对？</p>
<p>需要利用规则引擎，经过调研，选择了阿里的QLExpress，在页面上配置规则，生成对应的规则表达式，通过规则引擎执行计算</p>
<p>3、怎么进行双方数据源的核对？</p>
<p>见核对引擎-核对内核</p>
<p>4、如果对账数据源太大，怎么处理？</p>
<p>需要支持多种核对引擎</p>
<p>5、对账结果数据如何存储？如何应对数据量的日益增加？</p>
<p>由于需要在页面展示，所以存储选择存储在Mysql，后期进行分表处理</p>
<p>6、跨天导致的单边，如何处理？</p>
<p>需要支持跨对账周期，循环对账</p>
<h1 id="架构设计"><a href="#架构设计" class="headerlink" title="架构设计"></a>架构设计</h1><h2 id="业务架构"><a href="#业务架构" class="headerlink" title="业务架构"></a>业务架构</h2><img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-09-20_09-52-48.png" srcset="/img/loading.gif" lazyload alt="1">



<h2 id="数据架构"><a href="#数据架构" class="headerlink" title="数据架构"></a>数据架构</h2><img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-09-20_10-22-21.png" srcset="/img/loading.gif" lazyload alt="1">

<h1 id="组件及流程设计"><a href="#组件及流程设计" class="headerlink" title="组件及流程设计"></a>组件及流程设计</h1><img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-12_17-55-07.png" srcset="/img/loading.gif" lazyload alt="1">

<h2 id="配置"><a href="#配置" class="headerlink" title="配置"></a>配置</h2><p>主要负责对账场景的各种元数据配置。</p>
<p>1、对账场景配置：</p>
<img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-22_14-57-57.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom: 67%;">  

<p>2、清洗规则：</p>
<img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-21_18-25-52.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom: 67%;"> 

<p>3、核对规则：</p>
<img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-21_18-26-47.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom:70%;">  

<p>4、展示内容：</p>
<img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-21_18-27-05.png" srcset="/img/loading.gif" lazyload alt="1">  



<h2 id="数据接入"><a href="#数据接入" class="headerlink" title="数据接入"></a>数据接入</h2><img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-22_14-16-21.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom:80%;"> 

<p>职责：负责从业务方获取对账数据源，并解析为CSV文件，调用存储引擎进行存储</p>
<p>设计与实现实现：支持多种接入方式，目前系统实现了以下数据拉取方式</p>
<ul>
<li>SQL：主要用于内部业务系统，前期快速接入，后期建议接入接口，推拉账单</li>
<li>HTTP：使用HTTP进行远程通信，通过约定的格式对业务方对账源数据，进行拉取</li>
<li>微信、支付宝等：拉取三方支付平台等外部系统的账单，one by one的接入</li>
<li>MQ：如果是准实时对账，那就需要感知业务，监听业务方的MQ，然后做对应的处理 （可参考美团-对账系统）</li>
</ul>
<p>接口：</p>
<img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-22_15-23-34.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom:70%;">   

<figure><div class="code-wrapper"><pre class="line-numbers language-java" data-language="java"><code class="language-java"><span class="token comment">/**
 * 数据拉取器：从对账方的数据源中拉取数据
 */</span>
<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">DataPuller</span> <span class="token punctuation">&#123;</span>

    <span class="token comment">/**
     * 拉取对账数据源指定日期的源数据
     *
     * @param billMetaData
     * @return
     */</span>
    <span class="token keyword">void</span> <span class="token function">pull</span><span class="token punctuation">(</span><span class="token class-name">BillMetaData</span> billMetaData<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div></figure>





<h2 id="存储引擎"><a href="#存储引擎" class="headerlink" title="存储引擎"></a>存储引擎</h2><img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-22_14-14-24.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom:80%;"> 

<p>职责：对账源数据的存储、提取</p>
<p>设计与实现：在接口设计上，支持多种存储方式，目前采用的是SFTP服务器</p>
<p>示例：</p>
<img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-21_16-45-00.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom:80%;">  

<p>接口：</p>
<img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-22_15-26-28.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom:80%;">  

<figure><div class="code-wrapper"><pre class="line-numbers language-java" data-language="java"><code class="language-java"><span class="token comment">/**
 * 数据存储器：保存从DataPuller拉取到的原始账单
 */</span>
<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">DataSaver</span> <span class="token punctuation">&#123;</span>

    <span class="token keyword">void</span> <span class="token function">saveBill</span><span class="token punctuation">(</span><span class="token class-name">BillMetaData</span> billMetaData<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">void</span> <span class="token function">loadBill</span><span class="token punctuation">(</span><span class="token class-name">BillMetaData</span> billMetaData<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div></figure>



<h2 id="对账执行"><a href="#对账执行" class="headerlink" title="对账执行"></a>对账执行</h2><img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-22_14-11-46.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom:80%;">  

<h3 id="解析器"><a href="#解析器" class="headerlink" title="解析器"></a>解析器</h3><p>职责：将从存储引擎中取出的CSV文件，解析为Java内存中的标准的数据结构，用于后续流程操作</p>
<p>接口：</p>
<img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-22_15-28-21.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom:80%;">  

<figure><div class="code-wrapper"><pre class="line-numbers language-java" data-language="java"><code class="language-java"><span class="token comment">/**
 * 数据解析器：
 * 将从Saver中加载的数据，解析成统一的对账数据结构：List&lt;Map&lt;String, String>>
 */</span>
<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">DataParser</span> <span class="token punctuation">&#123;</span>

    <span class="token comment">/**
     * 将对账文件解析为对账标准数据结构
     *
     * @param tempBillFile
     * @return
     */</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Map</span><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">String</span><span class="token punctuation">></span><span class="token punctuation">></span></span> <span class="token function">parse</span><span class="token punctuation">(</span><span class="token class-name">File</span> tempBillFile<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">/**
     * 部分解析，用于数据量大的账单，分页解析
     * @param tempBillFile
     * @param startIndex
     * @param endIndex
     * @return
     */</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Map</span><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">String</span><span class="token punctuation">></span><span class="token punctuation">></span></span> <span class="token function">parse</span><span class="token punctuation">(</span><span class="token class-name">File</span> tempBillFile<span class="token punctuation">,</span> 
                                    <span class="token class-name">Integer</span> startIndex<span class="token punctuation">,</span> <span class="token class-name">Integer</span> endIndex<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div></figure>



<h3 id="清洗器"><a href="#清洗器" class="headerlink" title="清洗器"></a>清洗器</h3><p>职责：根据对账任务配置的清洗规则，对数据进行清洗、过滤、数据类型转换、汇总等操作  </p>
<p>接口：</p>
<figure><div class="code-wrapper"><pre class="line-numbers language-java" data-language="java"><code class="language-java"><span class="token comment">/**
 * 数据清洗器：将Parser解析后的数据，根据配置的规则进行分组、过滤、类型转换等处理
 */</span>
<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">DataCleaner</span> <span class="token punctuation">&#123;</span>

    <span class="token comment">/**
     * 清洗
     *
     *
     * @param taskDataSourceConfig
     * @param result
     * @return
     */</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Map</span><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">></span><span class="token punctuation">></span></span> <span class="token function">clean</span><span class="token punctuation">(</span><span class="token class-name">TaskDataSourceConfig</span> taskDataSourceConfig<span class="token punctuation">,</span> 
                                    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Map</span><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">String</span><span class="token punctuation">></span><span class="token punctuation">></span></span> result<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div></figure>





<h3 id="核对引擎"><a href="#核对引擎" class="headerlink" title="核对引擎"></a>核对引擎</h3><img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-22_14-19-11.png" srcset="/img/loading.gif" lazyload alt="1"> 

<p>职责：对清洗完成后的双方数据源，根据配置的核对规则，进行核对  </p>
<p>设计与实现：支持多种核对引擎，可动态切换，目前系统实现了以下核对引擎</p>
<ul>
<li>内存：因为目前我司采用D+1对账模式，现有的对账场景业务数据量并不大，所以在内存中直接核对，是最方便、效率最高的方式</li>
<li>Redis：如果数据量超过阈值，再使用内存核对，可能造成服务OOM，所以实现了基于Redis的核对引擎，用于大数据量的核对场景</li>
</ul>
<img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-21_17-02-48.png" srcset="/img/loading.gif" lazyload alt="1">

<p>接口：</p>
<img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-22_14-27-11.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom:80%;"> 

<figure><div class="code-wrapper"><pre class="line-numbers language-java" data-language="java"><code class="language-java"><span class="token comment">/**
 * 核对引擎
 */</span>
<span class="token keyword">public</span> <span class="token keyword">interface</span> <span class="token class-name">CheckEngine</span> <span class="token punctuation">&#123;</span>

    <span class="token comment">/**
     * 执行对账逻辑
     *
     * @param task
     */</span>
    <span class="token keyword">void</span> <span class="token function">check</span><span class="token punctuation">(</span><span class="token class-name">Task</span> task<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token comment">/**
     * 核对引擎类型
     *
     * @return
     */</span>
    <span class="token class-name">DataCheckEngineEnum</span> <span class="token function">getCheckEngineEnum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div></figure>





<h4 id="对账内核"><a href="#对账内核" class="headerlink" title="对账内核"></a>对账内核</h4><p>那具体怎么核对尼？其实原理很简单，如下图：</p>
<img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-21_17-05-15.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom:80%;">   

<p>核心代码：无论哪种核对引擎，对账的核心逻辑都是类似的</p>
<figure><div class="code-wrapper"><pre class="line-numbers language-java" data-language="java"><code class="language-java"><span class="token comment">/**
  * 核对引擎内核
  *
  * @param task
  * @param taskCheckRuleConfig
  * @param leftDataList
  * @param rightDataList
  * @throws Exception
  */</span>
<span class="token keyword">protected</span> <span class="token keyword">void</span> <span class="token function">doCheck</span><span class="token punctuation">(</span><span class="token class-name">Task</span> task<span class="token punctuation">,</span>
                       <span class="token class-name">TaskCheckRuleConfig</span> taskCheckRuleConfig<span class="token punctuation">,</span>
                       <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Map</span><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">></span><span class="token punctuation">></span></span> leftDataList<span class="token punctuation">,</span>
                       <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Map</span><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">></span><span class="token punctuation">></span></span> rightDataList<span class="token punctuation">)</span> <span class="token keyword">throws</span> <span class="token class-name">Exception</span> <span class="token punctuation">&#123;</span>
    <span class="token class-name">TaskRunLog</span> taskRunLog <span class="token operator">=</span> task<span class="token punctuation">.</span><span class="token function">getTaskRunLog</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">></span></span> leftShowFields <span class="token operator">=</span> task<span class="token punctuation">.</span><span class="token function">getLeftShowFields</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">></span></span> rightShowFields <span class="token operator">=</span> task<span class="token punctuation">.</span><span class="token function">getRightShowFields</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token class-name">TaskDataSourceConfig</span> leftTaskDataSourceConfig <span class="token operator">=</span> task<span class="token punctuation">.</span><span class="token function">getLeftTaskDataSourceConfig</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">TaskDataSourceConfig</span> rightTaskDataSourceConfig <span class="token operator">=</span> task<span class="token punctuation">.</span><span class="token function">getRightTaskDataSourceConfig</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token class-name">String</span> leftCheckKey <span class="token operator">=</span> leftTaskDataSourceConfig<span class="token punctuation">.</span><span class="token function">getCheckKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">String</span> rightCheckKey <span class="token operator">=</span> rightTaskDataSourceConfig<span class="token punctuation">.</span><span class="token function">getCheckKey</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token class-name">String</span> checkRuleExpression <span class="token operator">=</span> taskCheckRuleConfig<span class="token punctuation">.</span><span class="token function">getCheckRuleExpression</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    log<span class="token punctuation">.</span><span class="token function">info</span><span class="token punctuation">(</span><span class="token string">"[执行对账]taskId：&#123;&#125;,checkRuleExpression：&#123;&#125;"</span><span class="token punctuation">,</span> task<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> checkRuleExpression<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token class-name">AssertUtil</span><span class="token punctuation">.</span><span class="token function">notBlank</span><span class="token punctuation">(</span>checkRuleExpression<span class="token punctuation">,</span> <span class="token string">"[执行对账]checkRuleExpression为空,taskCheckRuleConfigId："</span> <span class="token operator">+</span> taskCheckRuleConfig<span class="token punctuation">.</span><span class="token function">getId</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">int</span> equalNum <span class="token operator">=</span> taskRunLog<span class="token punctuation">.</span><span class="token function">getEqualNum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> wrongNum <span class="token operator">=</span> taskRunLog<span class="token punctuation">.</span><span class="token function">getWrongNum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">int</span> leftMoreNum <span class="token operator">=</span> taskRunLog<span class="token punctuation">.</span><span class="token function">getLeftMoreNum</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token comment">// 可以优化一下：若右方数据是空的，则左边全为多帐</span>
    <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Object</span><span class="token punctuation">,</span> <span class="token class-name">List</span><span class="token punctuation">&lt;</span><span class="token class-name">Map</span><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">></span><span class="token punctuation">></span><span class="token punctuation">></span></span> rightDataMap <span class="token operator">=</span> rightDataList<span class="token punctuation">.</span><span class="token function">stream</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">collect</span><span class="token punctuation">(</span><span class="token class-name">Collectors</span><span class="token punctuation">.</span><span class="token function">groupingBy</span><span class="token punctuation">(</span>o <span class="token operator">-></span> o<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>rightCheckKey<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">></span></span> leftData <span class="token operator">:</span> leftDataList<span class="token punctuation">)</span> <span class="token punctuation">&#123;</span>
        <span class="token class-name">Object</span> checkKeyValue <span class="token operator">=</span> leftData<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>leftCheckKey<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token class-name">String</span> leftShowData <span class="token operator">=</span> <span class="token function">getShowData</span><span class="token punctuation">(</span>leftData<span class="token punctuation">,</span> leftShowFields<span class="token punctuation">)</span><span class="token punctuation">;</span>

        <span class="token class-name">List</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">Map</span><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">></span><span class="token punctuation">></span></span> rightValueList <span class="token operator">=</span> rightDataMap<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span>checkKeyValue<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token class-name">CollectionUtils</span><span class="token punctuation">.</span><span class="token function">isEmpty</span><span class="token punctuation">(</span>rightValueList<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">&#123;</span>
            <span class="token comment">// 因为前面的步骤，已经根据groupModel进行处理了，所以这里不用再考虑1个核对key，多行记录的情况</span>
            <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">></span></span> rightData <span class="token operator">=</span> rightValueList<span class="token punctuation">.</span><span class="token function">get</span><span class="token punctuation">(</span><span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token class-name">String</span> rightShowData <span class="token operator">=</span> <span class="token function">getShowData</span><span class="token punctuation">(</span>rightData<span class="token punctuation">,</span> rightShowFields<span class="token punctuation">)</span><span class="token punctuation">;</span>
            
            <span class="token comment">// 执行规则表达式</span>
            <span class="token class-name">DefaultContext</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">Object</span><span class="token punctuation">></span></span> context <span class="token operator">=</span> <span class="token class-name">QlExpress</span><span class="token punctuation">.</span><span class="token function">newContext</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            context<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token class-name">CheckPartEnum</span><span class="token punctuation">.</span><span class="token constant">LEFT</span><span class="token punctuation">.</span><span class="token function">getType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> leftData<span class="token punctuation">)</span><span class="token punctuation">;</span>
            context<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token class-name">CheckPartEnum</span><span class="token punctuation">.</span><span class="token constant">RIGHT</span><span class="token punctuation">.</span><span class="token function">getType</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> rightData<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token class-name">Boolean</span> checkResult <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token class-name">Boolean</span><span class="token punctuation">)</span> <span class="token class-name">QlExpress</span><span class="token punctuation">.</span>runner<span class="token punctuation">.</span><span class="token function">execute</span><span class="token punctuation">(</span>checkRuleExpression<span class="token punctuation">,</span> context<span class="token punctuation">,</span> <span class="token keyword">null</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token class-name">BooleanUtils</span><span class="token punctuation">.</span><span class="token function">isTrue</span><span class="token punctuation">(</span>checkResult<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">&#123;</span>
                <span class="token comment">// 平账</span>
                equalNum<span class="token operator">++</span><span class="token punctuation">;</span>
                taskRunLog<span class="token punctuation">.</span><span class="token function">createEqualDetail</span><span class="token punctuation">(</span>checkKeyValue<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> leftShowData<span class="token punctuation">,</span> rightShowData<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">&#125;</span> <span class="token keyword">else</span> <span class="token punctuation">&#123;</span>
                <span class="token comment">// 错账</span>
                wrongNum<span class="token operator">++</span><span class="token punctuation">;</span>
                taskRunLog<span class="token punctuation">.</span><span class="token function">createWrongDetail</span><span class="token punctuation">(</span>checkKeyValue<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> leftShowData<span class="token punctuation">,</span> rightShowData<span class="token punctuation">)</span><span class="token punctuation">;</span>
            <span class="token punctuation">&#125;</span>
            rightData<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token constant">DEAL_FLAG</span><span class="token punctuation">,</span> <span class="token boolean">true</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">&#125;</span> <span class="token keyword">else</span> <span class="token punctuation">&#123;</span>
            <span class="token comment">// left多帐</span>
            leftMoreNum<span class="token operator">++</span><span class="token punctuation">;</span>
            taskRunLog<span class="token punctuation">.</span><span class="token function">createLeftMoreDetail</span><span class="token punctuation">(</span>checkKeyValue<span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> leftShowData<span class="token punctuation">,</span> <span class="token constant">JSON</span><span class="token punctuation">.</span><span class="token function">toJSONString</span><span class="token punctuation">(</span>leftData<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">&#125;</span>
    <span class="token punctuation">&#125;</span>

    taskRunLog<span class="token punctuation">.</span><span class="token function">setEqualNum</span><span class="token punctuation">(</span>equalNum<span class="token punctuation">)</span>
        <span class="token punctuation">.</span><span class="token function">setWrongNum</span><span class="token punctuation">(</span>wrongNum<span class="token punctuation">)</span>
        <span class="token punctuation">.</span><span class="token function">setLeftMoreNum</span><span class="token punctuation">(</span>leftMoreNum<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div></figure>





<h2 id="差错处理器"><a href="#差错处理器" class="headerlink" title="差错处理器"></a>差错处理器</h2><p>职责：把对账结果非平账的数据，进行二次核对，如果仍然有错误，做对应的处理</p>
<ul>
<li>二次核对：主要是处理日切的数据，因为按照D+1进行对账，可能存在双方的数据跨天</li>
<li>差错处理：主要是告警</li>
</ul>
<h2 id="结果展示"><a href="#结果展示" class="headerlink" title="结果展示"></a>结果展示</h2><img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-22_14-08-08.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom:80%;"> 

<p><b></b></p>
<img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-22_14-10-40.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom:75%;"> 

<p><b></b></p>
<img src="/2023/08/05/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1%EF%BC%9A%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/Snipaste_2023-12-22_16-45-42.png" srcset="/img/loading.gif" lazyload alt="1" style="zoom:75%;">  

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E7%B3%BB%E7%BB%9F%E8%AE%BE%E8%AE%A1/" class="category-chain-item">系统设计</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/%E9%80%9A%E7%94%A8%E5%AF%B9%E8%B4%A6%E4%B8%AD%E5%BF%83/" class="print-no-link">#通用对账中心</a>
      
        <a href="/tags/QLExpress/" class="print-no-link">#QLExpress</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>系统设计：通用对账中心</div>
      <div>http://example.com/2023/08/05/系统设计：通用对账中心/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>XiaoMaDing</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2023年8月5日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2023/07/20/%E7%94%9F%E4%BA%A7%E4%BA%8B%E6%95%85%EF%BC%9A%E4%BA%8B%E5%8A%A1%E4%B8%8E%E9%94%81/" title="生产事故：事务与锁">
                        <span class="hidden-mobile">生产事故：事务与锁</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  
  
    <article id="comments" lazyload>
      
  <div id="valine"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#valine', function() {
      Fluid.utils.createScript('https://lib.baomitu.com/valine/1.5.1/Valine.min.js', function() {
        var options = Object.assign(
          {"appId":"fwhgdRnxBMBQuwXd6G2KY7uA-gzGzoHsz","appKey":"wz9qgHwvuMw8Y0yXAvL1KEr4","path":"window.location.pathname","placeholder":null,"avatar":"retro","meta":["nick","mail","link"],"requiredFields":[],"pageSize":10,"lang":"zh-CN","highlight":false,"recordIP":false,"serverURLs":"","emojiCDN":null,"emojiMaps":null,"enableQQ":false},
          {
            el: "#valine",
            path: window.location.pathname
          }
        )
        new Valine(options);
        Fluid.utils.waitElementVisible('#valine .vcontent', () => {
          var imgSelector = '#valine .vcontent img:not(.vemoji)';
          Fluid.plugins.imageCaption(imgSelector);
          Fluid.plugins.fancyBox(imgSelector);
        })
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


    </article>
  


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script  src="https://lib.baomitu.com/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js" ></script>

  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
